from jili.core.convert import str2datetime
limit2date=str2datetime("20200824")
def get_limit_rate(obj, d=None):
    # 300 :20200824
    r = 0.1
    # if obj[:3] == "002":
    #     if d:
    #         d = str2datetime(d)
    #         if d >= limit2date:
    #             r = 0.2
    #     else:
    #         r = 0.2
    if obj[:2] == "30":
        if d:
            d = str2datetime(d)
            if d >= limit2date:
                r = 0.2
        else:
            r = 0.2
    elif obj[:2] == "68":
        r = 0.2
    return r
def calc_uplimite_price(obj, price, d=None):
    r = get_limit_rate(obj, d)
    return round(price * (1 + r), 2)
def calc_downlimite_price(obj, price, d=None):
    r = get_limit_rate(obj, d)
    return round(price * (1 - r), 2)
def calc_updownlimite_price(obj, price, d=None):
    r = get_limit_rate(obj, d)
    return round(price * (1 + r), 2),round(price * (1 - r), 2)